package bbb;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class BallMap {

	public static List<BallInfo> data = new ArrayList<BallInfo>();
	
	public static void loadData(){
		loadData("C:\\Users\\Administrator\\Desktop\\双色球\\r.txt");
	}

	public static void loadData(String filePath) {
		try {
			FileInputStream fis = new FileInputStream(filePath);
			InputStreamReader isr = new InputStreamReader(fis);
			BufferedReader bReader = new BufferedReader(isr);
			String s = null;
			while ((s = bReader.readLine()) != null) {
				BallInfo bi = ParserUtils.parse(s);
				if (bi != null) {
					data.add(bi);
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static List<BallInfo> ballBefore(int count) {
		List<BallInfo> list = new ArrayList<BallInfo>();
		for (int i = data.size() - 1; i >= data.size() - count; i--) {
			list.add(data.get(i));
		}

		return list;
	}
	
	public static BallInfo ballAt(int count) {
		return data.get(data.size() - count - 1);
	}
}
